package com.hmall.api.interceptors;

import com.hmall.common.utils.UserContext;
import feign.RequestInterceptor;
import feign.RequestTemplate;

/**
 * @program: springcloud-study
 * @description:
 * @author: flyduck
 * @create: 2025-04-09 20:22
 **/
public class UserInfoRequestInterceptor implements RequestInterceptor {
    @Override
    public void apply(RequestTemplate requestTemplate) {
        Long userId = UserContext.getUser();
        if (userId != null) {
            requestTemplate.header("user-info", userId.toString());
        }
    }
}
